package com.zilu.digitaltwin.common.enums;

import com.zilu.digitaltwin.dto.req.JobResidenceReqDTO;

/**
 * @author :caijianbao
 * @date : 2023/2/3 11:53
 */
public enum JobResidenceAnalysisApiEnum {

    STUDENTS_ANALYSIS("student", "", "studentsRouteAnalysis"),

    TEACHERS_ANALYSIS("teacher", "", "teachersJobResidenceAnalysis"),

    STUDENTS_OVERVIEW_GRID("student", "grid", "studentsRouteOverviewByGrid"),

    TEACHERS_OVERVIEW_GRID("teacher", "grid", "teachersJobResidenceOverviewByGrid");

    private String type;

    private String overviewType;

    private String apiName;

    JobResidenceAnalysisApiEnum(String type, String overviewType, String apiName) {
        this.type = type;
        this.overviewType = overviewType;
        this.apiName = apiName;
    }

    /**
     * 根据jobResidenceReqDTO获取apiName 默认返回教师的详细的职住分析接口
     *
     * @param jobResidenceReqDTO
     * @return
     */
    public static String getApiName(JobResidenceReqDTO jobResidenceReqDTO) {
        String overviewType = "";
        if (jobResidenceReqDTO.getWithOverview()) {
            overviewType = jobResidenceReqDTO.getOverviewType() == null ? "grid" : jobResidenceReqDTO.getOverviewType();
        }
        for (JobResidenceAnalysisApiEnum value : JobResidenceAnalysisApiEnum.values()) {
            if (value.getType().equalsIgnoreCase(jobResidenceReqDTO.getType())
                    && value.getOverviewType().equalsIgnoreCase(overviewType)) {
                return value.getApiName();
            }
        }
        return TEACHERS_ANALYSIS.getApiName();
    }

    public String getType() {
        return type;
    }

    public String getOverviewType() {
        return overviewType;
    }

    public String getApiName() {
        return apiName;
    }
}
